package com.lujieni.threadpool.context;

import com.lujieni.threadpool.config.Context;

public class ContextHolder {

    /**
     * 只有在主线程里创建子线程的时候才能赋值
     */
    private static final ThreadLocal<Context> userThreadLocal = new InheritableThreadLocal<>();
 
    public static void setContext(Context context) {
        userThreadLocal.set(context);
    }
 
    public static Context getContext() {
        return userThreadLocal.get();
    }
 
    public static void clearContext() {
        userThreadLocal.remove();
    }
}